package org.wenhuayuan.project.main.demo.dispatchTouch;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class MyFrameLayout extends FrameLayout {
    public final static String TAG_ACTION_DISPATCH = "TAG_ACTION_DISPATCH";
    public MyFrameLayout(@NonNull Context context) {
        super(context);
        init();
    }

    public MyFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public MyFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }
    private void init() {
        setBackgroundColor(Color.parseColor("#DB7093"));
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        Log.i(TAG_ACTION_DISPATCH, "====== MyFrameLayout-onInterceptTouchEvent ====== ");
        boolean sup = super.onInterceptTouchEvent(ev);
        Log.i(TAG_ACTION_DISPATCH, "MyFrameLayout-onInterceptTouchEvent+sup = " +sup);
        return sup;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        Log.i(TAG_ACTION_DISPATCH, "====== MyFrameLayout-dispatchTouchEvent ======");
        boolean sup = super.dispatchTouchEvent(ev);
        Log.i(TAG_ACTION_DISPATCH, "MyFrameLayout-dispatchTouchEvent+sup = " +sup);
        return sup;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.i(TAG_ACTION_DISPATCH, "====== MyFrameLayout-onTouchEvent ====== ");
        boolean sup = super.onTouchEvent(event);
        Log.i(TAG_ACTION_DISPATCH, "MyFrameLayout-onTouchEvent+sup = " +sup);
        return sup;
    }
}
